feat: add user agent header using gRPC interceptor#2199
Conversation
Signed-off-by: oGranny <ogranny.github.io@gmail.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 9 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
Adds a gRPC client interceptor to inject an SDK-identifying x-user-agent metadata header into all outgoing consensus-node and mirror-node gRPC calls, enabling node-side telemetry attribution (Fixes #2169).
Changes:
- Introduces
_UserAgentInterceptorthat appendsx-user-agent: hiero-sdk-python/{version|dev}to outgoing unary-unary and unary-stream RPCs. - Wraps consensus-node and mirror-node channels with
grpc.intercept_channel(...)to apply the interceptor. - Adds unit tests covering header value construction and metadata injection behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/unit/channel_interceptor_test.py | Adds unit tests validating user-agent value resolution and metadata injection for unary RPC types. |
| src/hiero_sdk_python/node.py | Implements _UserAgentInterceptor and applies it to node gRPC channels. |
| src/hiero_sdk_python/client/client.py | Applies the interceptor to the mirror-node gRPC channel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a gRPC client interceptor that injects an ChangesUser-Agent Interceptor and Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2012e306-221c-483d-882c-3b737276c1f5
📒 Files selected for processing (3)
src/hiero_sdk_python/client/client.pysrc/hiero_sdk_python/node.pytests/unit/channel_interceptor_test.py
Signed-off-by: oGranny <ogranny.github.io@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #2199 +/- ##
==========================================
+ Coverage 93.73% 93.75% +0.01%
==========================================
Files 145 145
Lines 9483 9508 +25
==========================================
+ Hits 8889 8914 +25
Misses 594 594 🚀 New features to boost your workflow:
|
|
@oGranny, Please apply the pre-commit on the PR |
|
@oGranny Please let us know if you need assistance applying pre-commit |
Signed-off-by: oGranny <ogranny.github.io@gmail.com>
Done, apologies for the delay. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unit/channel_interceptor_test.py (1)
31-104: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winAdd integration guards for
grpc.intercept_channelusage inClientand_Node.Current tests validate interceptor internals, but they don’t fail if channel wiring is accidentally removed from
Client._init_mirror_stub()or_Node._get_channel(). Add unit tests that monkeypatchgrpc.intercept_channeland assert it is invoked with_UserAgentInterceptorin both flows.As per coding guidelines, "Unit tests should be extensive - test even if we don't expect users to use it currently."
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6ac91ab9-bcbe-45e9-9928-2629308b005c
📒 Files selected for processing (4)
src/hiero_sdk_python/channels.pysrc/hiero_sdk_python/client/client.pysrc/hiero_sdk_python/node.pytests/unit/channel_interceptor_test.py
manishdait
left a comment
There was a problem hiding this comment.
@oGranny, Seems good to me, just update the branch
|
@oGranny Thank you!! |
Signed-off-by: oGranny <ogranny.github.io@gmail.com>
Signed-off-by: oGranny <ogranny.github.io@gmail.com>
Description:
Added gRPC client interceptor,
_UserAgentInterceptor, which adds anx-user-agentheader to all outgoing gRPC requests, identifying the SDK and its version.Related issue(s):
Fixes #2169
Checklist